package cn.eastseven;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.apache.log4j.Logger;

public class MessageReceiver implements MessageListener {

	private static final Logger log = Logger.getLogger(MessageReceiver.class);
	
	@Override
	public void onMessage(Message message) {
		if (message instanceof TextMessage) {
			TextMessage textMessage = (TextMessage) message;
			try {
				String text = textMessage.getText();
				log.info(String.format("Received: %s", text));
			} catch (JMSException e) {
				e.printStackTrace();
			}
		}
	}

}
